import { ref } from 'vue';
import { getAdvanceChargeRecordApi } from '@/api/sj/financialManagement/advancePaymentManagement'

const usePrepaymentDetails = () => {

    const prepaymentDetailsVisible = ref(false);
    const prepaymentDetailsData = ref();
    const prepaymentDetailsRow = ref();

    /** 打开 查看预付款详情 弹窗 */
    const handlOpenPrepaymentDetails = async (row?: any) => {

        try {
            const {data} = await getAdvanceChargeRecordApi(row.id)
            prepaymentDetailsData.value = data
        } catch (error) {
            
        }
        prepaymentDetailsRow.value = row;
        prepaymentDetailsVisible.value = true;
    };

    /** 关闭 查看预付款详情 弹窗 */
    const handleClosePrepaymentDetails = () => {
        prepaymentDetailsVisible.value = false;
    };

    return {
        prepaymentDetailsVisible,
        prepaymentDetailsData,
        prepaymentDetailsRow,
        handlOpenPrepaymentDetails,
        handleClosePrepaymentDetails
    }
};

export default usePrepaymentDetails;
